function create_updated_collection(collectionA, objectB) {
  let  collection=[];
  for (let i=0;i<collectionA.length;)
    {
      let count=0;
      for (let j=i;j<collectionA.length;j++)
        {
          if (collectionA[i]==collectionA[j])
            count+=1;
        } 
      collection.push({"key":collectionA[i],"count":count});
      i+=count;
    } 
  for (let a=0;a<collection.length;a++)
    {
      for (let b=0;b<objectB["value"].length;b++)
        {
          if (collection[a]["key"]==objectB["value"][b])
            collection[a]={"key":collection[a]["key"],"count":collection[a]["count"]-parseInt(collection[a]["count"]/3)}
        }
    }
  return collection;
}

module.exports = create_updated_collection;
